package ti.me.seek2chat.utilities

import android.content.Context
import android.content.SharedPreferences
/**
 * PreferenceManager.kt
 *
 * 这个文件包含了PreferenceManager类，用于管理应用程序的SharedPreferences。
 * 通过这个类，可以方便地存储和检索用户的偏好设置。
 */
class PreferenceManager(context: Context) {
    private var sharedPreferences: SharedPreferences = context.getSharedPreferences(Constants.KEY_PREFERENCE_NAME, Context.MODE_PRIVATE)


    fun putBoolean(key: String, value: Boolean) {
        val editor = sharedPreferences.edit()
        editor?.putBoolean(key, value)
        editor?.apply()
    }

    fun getBoolean(key: String): Boolean {
        return sharedPreferences.getBoolean(key, false)
    }

    fun putString(key: String, value: String) {
        val editor = sharedPreferences.edit()
        editor?.putString(key, value)
        editor?.apply()
    }

    fun getString(key: String): String? {
        return sharedPreferences.getString(key, null)
    }

    fun clear() {
        val editor = sharedPreferences.edit()
        editor?.clear()
        editor?.apply()
    }
}